<%--
  Created by IntelliJ IDEA.
  User: wesley.wei
  Date: 2018-06-01
  Time: 13:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>layout 后台大布局 - Layui</title>
    <link rel="stylesheet" href="/componments/layui/css/layui.css">
    <style>
        .grid-demo-bg1 {
            background-color: #63BA79;
        }
        .grid-demo {
            background-color: #63BA78;
        }
    </style>
</head>
<body class="layui-layout-body">

<div class="layui-btn-group">
    <button class="layui-btn" onclick="addTopic()">增加</button>
    <button class="layui-btn" onclick="editUser()">编辑</button>
    <button class="layui-btn">删除</button>
    <button class="layui-btn" onclick="showTopic()">查看</button>
</div>

<table class="layui-table" lay-data="{url:'/topic/page', page:true, id:'topicTable'}" lay-filter="test">
    <thead>
    <tr>
        <th lay-data="{checkbox:true, fixed: true}"></th>
        <th lay-data="{field:'id', sort: true}">ID</th>
        <th lay-data="{field:'title'}">标题</th>
    </tr>
    </thead>
</table>

<script src="/componments/layui/layui.js"></script>
<script>
    //JavaScript代码区域
    /* layui.use('element', function(){
      var element = layui.element;
    }); */
    var table = undefined;

    layui.use(['element','table'], function(){
        table = layui.table;

        /* var $ = layui.$, active = {
          getCheckData: function(){ //获取选中数据
            var checkStatus = table.checkStatus('userTable')
            ,data = checkStatus.data;
            layer.alert(JSON.stringify(data));
          }
          ,getCheckLength: function(){ //获取选中数目
            var checkStatus = table.checkStatus('userTable')
            ,data = checkStatus.data;
            layer.msg('选中了：'+ data.length + ' 个');
          }
          ,isAll: function(){ //验证是否全选
            var checkStatus = table.checkStatus('userTable');
            layer.msg(checkStatus.isAll ? '全选': '未全选')
          }
        };

        $('.demoTable .layui-btn').on('click', function(){
          var type = $(this).data('type');
          active[type] ? active[type].call(this) : '';
        }); */

    });

    function addTopic(){
        location.href = '/web/topic/add'
    }
    
    function showTopic() {
        var checkStatus = table.checkStatus('topicTable');
        data = checkStatus.data;
        if(data == ''){
            layer.alert('请选择数据');
            return false;
        }

        location.href = '/web/topic/show?id='+data[0].id;
    }
</script>
</body>
</html>
